using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeAutoAim:Upgrade {

	protected override void ProjectileFiringEventHandler(object _sender,ProjectileEventArgs e) {
		base.ProjectileFiringEventHandler(_sender,e);
		Projectile sender = _sender as Projectile;

		Mob target = Utility.FindNearestMob(sender.transform.position,100,
			x => {
				if(!sender.shooterMob) return x.IsSelfVisible();
				if(FactionManager.GetRelation(x.faction,sender.shooterMob.faction)>=0) return false;
				if(!sender.shooterMob.IfLineOfSight(x)) return false;
				return true;
			}
		);
		if(target!=null) sender.forward=target.position-(Vector2)sender.transform.position;
	}

}
